<div class="wrapper activity-box">
	<empty name="prizeInfo">
		<div class="activity-box-container">
			<img id="box-img" src="__STYLE__/Box/images/box{$hostInfo.boxId}.png">
		</div>
		<div class="activity-process">
			<gt name="hostInfo.diff" value="0">
				已经有 <span>{$hostInfo.openCount}</span> 位朋友帮你拆盒子了，还差 <span>{$hostInfo.diff}</span> 位就可以打开盒子赢取礼品了！
				<else /> 
				已经有 <span>{$hostInfo.openCount}</span> 位朋友帮你拆盒子了，你现在就可以打开盒子赢取礼品了！
				<a id="btn-open" class="button button-block button-rounded button-flat-caution">打开盒子赢取礼品</a>
			</gt>
		</div>
		<div class="wrapper activity-action">
			<a id="btn-play" class="button button-block button-rounded button-flat-royal">请朋友帮忙开盒子</a>
			<gt name="hostInfo.diff" value="0">
				<a class="button button-block button-rounded button-flat-caution disabled">打开盒子赢取礼品</a>
				<else />
				<a id="btn-open" class="button button-block button-rounded button-flat-caution">打开盒子赢取礼品</a>
			</gt>
		</div>
		<script type="text/javascript">
			wechatData.link = activity.playUrl;
			wechatData.desc = "我还差 " + hostInfo.diff + " 位朋友帮忙就可以拆开盒子赢取礼品了，快来帮帮我吧~";
		</script>
		<else />
		<div class="activity-box-container">
			<img id="box-img" src="__STYLE__/Box/images/open.png">
		</div>
		<div class="activity-process">
			<empty name="prizeInfo.prizeName">
				您已经打开了盒子，但很遗憾，盒子里面是空的……
				<else /> 恭喜您已经打开了盒子，并在盒子里面发现了奖品：
				<span>{$prizeInfo.prizeName}</span> <notempty name="prizeInfo.prizeCode">(序列码：{$prizeInfo.prizeCode})，快点去您的商城个人中心查看吧^_^</notempty>！
			</empty>
		</div>
		<div class="wrapper activity-action">
			<a id="btn-play" class="button button-block button-rounded button-flat-royal">分享给朋友们</a>
			<empty name="prizeInfo.prizeCode"><a id="btn-register" class="button button-block button-rounded button-flat-caution">登记领奖信息</a></empty>
		</div>
		<div class="wrapper activity-process activity-register display-none">
			<empty name="registerInfo">
				<form name="form-register">
					<input type="text" id="name" name="name" value="" placeholder="请输入姓名">
					<input type="tel" id="tel" name="tel" value="" placeholder="请输入电话">
					<input type="text" id="address" name="address" value="" placeholder="请输入地址">
					<input type="text" id="zip" name="zip" value="" placeholder="请输入邮编">
					<a id="bt-submit" class="button button-block button-rounded button-flat-primary">提交信息</a>
				</form>
				<else />
				<h3>您的登记信息如下：</h3>
				<ul>
					<li>姓名: {$registerInfo.name}</li>
					<li>电话: {$registerInfo.tel}</li>
					<li>地址: {$registerInfo.address}</li>
					<li>邮编: {$registerInfo.zip}</li>
				</ul>
			</empty>
		</div>
		<script type="text/javascript">
			wechatData.link = activity.sharePrizeUrl;
			wechatData.desc = "在好友的帮助下，我打开了盒子，<notempty name='prizeInfo.prizeName'>获得了奖品（{$prizeInfo.prizeName}），</notempty>你也快来参加吧！";
		</script>
	</empty>
</div>


<div class="wrapper activity-process">
	<h3>帮助我拆盒子的朋友</h3>
	<ol>
		<volist name="playList" id="vo">
			<li><span class="float-right">{$vo.time}</span>{$vo['nickname']?$vo['nickname']:"(匿名朋友)"}</li>
		</volist>
	</ol>
</div>

<script type="text/javascript">
	$(function() {
		var boxId = 1;
		$("#btn-play").click(function() {
			simapp.tips("分享给你的小伙伴也来参与吧！");
		});
		$("#btn-register").click(function() {
			$(".activity-register").toggleClass('display-none');
		})
		$("#bt-submit").click(function() {
			if ($("#name").val() == "") {
				simapp.toast("姓名不能为空");
				return;
			}
			if ($("#tel").val() == "") {
				simapp.toast("电话不能为空");
				return;
			}
			if ($("#address").val() == "") {
				simapp.toast("地址不能为空");
				return;
			}
			if ($("#zip").val() == "") {
				simapp.toast("邮编不能为空");
				return;
			}
			$.ajax({
				type: "POST",
				url: "__CONTROLLER__/ajaxRegister?debug",
				async: true,
				data: {
					uid: userInfo.id,
					cid: "{$hostInfo.cid}",
					aid: "{$hostInfo.aid}",
					hid: "{$hostInfo.id}",
					name: $("#name").val(),
					tel: $("#tel").val(),
					address: $("#address").val(),
					zip: $("#zip").val()
				},
				beforeSend: function() {
					simapp.toast('正在提交信息……');
				},
				success: function(res) {
					simapp.toast(res.msg);
					if (res.state == 1) {
						location.href = "__CONTROLLER__/myBox/cid/{$activity.cid}/aid/{$activity.id}/debug/{$Think.get.debug}"
					}
				},
				error: function() {
					simapp.toast("网络不太好哦， 请过会再试~！");
				}
			})
		});
		$("#btn-open").click(function() {
			$.ajax({
				type: "POST",
				url: "__CONTROLLER__/ajaxGetPrize?debug",
				async: true,
				data: {
					uid: userInfo.id,
					cid: "{$hostInfo.cid}",
					aid: "{$hostInfo.aid}",
					hid: "{$hostInfo.id}"
				},
				beforeSend: function() {
					simapp.toast('正在打开盒子……');
				},
				success: function(res) {
					simapp.toast(res.msg);
					if (res.state == 1) {
						location.href = "__CONTROLLER__/myBox/cid/{$activity.cid}/aid/{$activity.id}/debug/{$Think.get.debug}"
					}
				},
				error: function() {
					simapp.toast("网络不太好哦， 请过会再试~！");
				}
			});
		})
	});
</script>